/*
 * @Author: wangyu
 * @Date: 2025-01-17 16:37:34
 * @LastEditTime: 2025-02-14 17:39:23
 * @LastEditors: wangyu
 * @Description:
 * @FilePath: \website\server\api\GetTodayAvailableHotspots.ts
 */
import { $fetch } from "ofetch";
import type { CustomResponse } from "~~/types";
import { BASE_URL } from "../utils/constants";

// async function fetchTodayAvailableHotspots(id: string): Promise<User> {
async function GetTodayAvailableHotspots(): Promise<CustomResponse<any>> {
  const data = await $fetch(`/GetTodayAvailableHotspots`, {
    baseURL: BASE_URL,
  });
  return data.data;
}

export default defineCachedEventHandler(
  (event) => {
    // const { id } = getQuery(event) as { id?: string }

    // if (!id) {
    //   throw createError({
    //     statusCode: 422,
    //     statusMessage: 'Must provide a user ID.',
    //   })
    // }
    console.log("获取数据");
    return GetTodayAvailableHotspots();
  },
  {
    name: "api/GetTodayAvailableHotspots",
    // getKey(event) {
    //   const { id } = getQuery(event)
    //   return ['user', id].join('/')
    // },
    swr: false,
    maxAge: 60,
  }
);
